package net.udp;

import java.net.DatagramPacket;
import java.net.SocketException;
import java.util.Date;

public class UDPDaytimeServer extends UDPSever
{
	public final static int DEFAULT_PORT = 13;
	public UDPDaytimeServer() throws SocketException
	{
		super(DEFAULT_PORT);
	}
	@Override
	public void respond(DatagramPacket request)
	{
		try
		{
			Date now = new Date();
			String response = now.toString()+"\r\n";
			byte[] data = response.getBytes("ASCII");
			DatagramPacket outgoing = new DatagramPacket(data, data.length, request.getAddress(),request.getPort());
			socket.send(outgoing);
		}
		catch (Exception e)
		{
		}
	}
	
}
